# -*- coding: utf-8 -*-
"""
尝试禁用AppPublish审批
"""

import sys
from pathlib import Path

# 添加项目根目录到路径
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))

from src.llm.hiagent_app.utils.api_client import HiAgentAPIClient
import json

def disable_approval():
    """禁用AppPublish审批"""
    client = HiAgentAPIClient()

    print("=" * 80)
    print("[INFO] Attempting to disable AppPublish approval")
    print("=" * 80)

    try:
        # 尝试更新审批配置，将AppPublish设置为Disabled
        result = client.make_request(
            action="UpdateApprovalConfig",
            body={
                "Kind": "AppPublish",
                "Type": "Disabled",
                "Top": {}
            }
        )

        print("\n[SUCCESS] Approval config updated!")
        print(json.dumps(result, indent=2, ensure_ascii=False))

    except Exception as e:
        print(f"\n[ERROR] Failed to update approval config: {str(e)}")
        print("\n[INFO] This might require admin privileges.")
        print("[INFO] Alternative solution: Use a different user account with approval permissions.")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    disable_approval()
